package com.hxl.linuxfilemanager.controller;

import com.hxl.linuxfilemanager.entity.R;
import com.hxl.linuxfilemanager.util.ProcessUtils;
import com.hxl.linuxfilemanager.util.ResponseUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/process")
public class ProcessController {

    @GetMapping("list")
    public R listProcess(){
        return ResponseUtils.suceess("OK", ProcessUtils.listAllProcess());
    }

    @PostMapping("stopProcess")
    public   R stopProcess(@RequestParam("pid") int pid){
            R  result =ProcessUtils.stopProcess(pid)!=0?ResponseUtils.error(-1,"终止失败"): ResponseUtils.suceess("终止成功","");
            return result;
    }
}
